Why isn't `"repeat" * 3` the same as `3 * "repeat"` in Ruby?

Posted by levirg on Stack Overflow See other posts from Stack Overflow or by levirg
Published on 2010-03-30T06:59:33Z Indexed on 2010/03/30 12:03 UTC
Read the original article Hit count: 238

Filed under:

When I type this:

puts 'repeat' * 3

I get:

>> repeat repeat repeat

But it's not working if I do this:

puts 3 * 'repeat'

Why?

© Stack Overflow or respective owner

Related posts about ruby